<template>
	<div>

		<h1 style="margin: 20px;">商品库存查询</h1>

		<van-field v-model="keyword" center clearable label="输入关键字" placeholder="请输入sku包含的关键字">
			<template #button>
				<van-button size="small" type="primary" v-on:click="searchKeyword_">查询SKU数量</van-button>
			</template>
		</van-field>

		<div v-for="item in quantity_" style="margin: 5px;">

			<SkuInfo v-bind:sku-id='item.id'></SkuInfo>

		</div>

		<div style="height: 100px;"></div>

		<!-- <SkuInfo sku-id='155'></SkuInfo> -->

	</div>
</template>

<script>
	import SkuInfo from "../sku_info/index.vue"
	import all_sku from "../../utils/select_all_sku.js"
	import {
		Toast
	} from 'vant'
	import {
		select_sum_sku_account_url
	} from "../../utils/setting.js"
	export default {
		name: '',
		components: {
			SkuInfo
		},
		props: {},
		data() {
			return {
				quantity: [],
				quantity_: [],

				keyword: '',
			}
		},
		methods: {

			searchKeyword_() {
				this.$router.push({
					name: 'GoodsQuantity',
					query: {
						keyword: this.keyword
					}
				})

				location.reload()
			},


			searchKeyword(keyword) {

				this.quantity_ = new Array()

				this.keyword = keyword

				if (this.keyword == '') {
					Toast('请输入关键字')

					return
				}

				for (let i of this.quantity) {
					// console.log(i)
					if (i.value.toLowerCase().indexOf(this.keyword.toLowerCase()) != -1) {
						// console.log(i.value.toLowerCase().indexOf(this.keyword.toLowerCase()))
						this.quantity_.push(i)
					}
				}

				// console.log(this.quantity_)
			},

		},
		computed: {},
		watch: {},
		created() {},
		mounted() {

			// this.get_goods_sum()
			
			let key_word = this.$route.query.keyword
			// undefined


			all_sku(
				res => {
					// console.log(res)
					this.quantity = res
					if(key_word != undefined && key_word != ''){
						this.searchKeyword(key_word)
					}

				}
			)
			
			// console.log(this.$route.query.keyword)





		},
	}
</script>

<style scoped lang="less">
	.cell_header_title {
		background-color: #F0F0F0;
		font-weight: 800;
	}
</style>
